Repository navigation
Read u32 values only from SHORT and LONG entries, as C++ does - #21
Merged
copybara-service[bot] merged 1 commit intoNov 5, 2026
Merged
Conversation
1c3t3a
approved these changes
Nov 5, 2026
1c3t3a
left a comment
There was a problem hiding this comment.
Yes we want to do the same as C++, thanks a lot for the PR Kunal!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Read u32 values only from SHORT and LONG entries, as C++ does
Problem
TiffDirectory::Getfor auint32_t(C++, Rust) reads a tag's value as a number: the orientation, the image sizes and offsets, and the Exif and GPS pointers all go through it. C++ reads only SHORT and LONG entries. The port'sget_u32_vec, whichget_u32calls, also reads entries of type IFD (13), although its doc comment saysShortandLong. For example:The CR3's orientation is the same from
Cr3GetPreviewDataandCr3GetOrientation. In the last row, an Orientation that does not read fails the directory in C++; the port does the same, but its read succeeds.Question
Which behaviour do we want: C++'s or the Rust port's? Specifically, for a value stored in an entry of type IFD, should reading it as a
uint32_tfail (like the C++ library), or give the value as if it were a LONG (like the Rust port)?This PR implements C++'s behaviour.
Fix
get_u32_vecreads SHORT and LONG entries only, as its doc comment says and as C++'sGetdoes, and its second match drops the IFD arm it no longer reaches:The examples above then match C++. Replayed before and after:
Of the campaigns' inputs, one CR3 differs from C++ in its orientation on main and none with this PR; no other input changes. The port's tests pass unchanged (44 + 174).
Notes for review: